const { tranListToTreeData } = require('../dist/hysjUtils.min.js')

const arr = [
  { id: 0, pId: -1, name: '陕西省'},
  { id: 1, pId: 0, name: '延安市'},
  { id: 2, pId: 0, name: '西安市'},
  { id: 3, pId: 1, name: '子长县'},
  { id: 4, pId: 1, name: '志丹县'},
  { id: 5, pId: 1, name: '延长县'},
  { id: 6, pId: 1, name: '宜川县'},
  { id: 7, pId: 1, name: '富县'},
  { id: 8, pId: 2, name: '长安区'},
  { id: 9, pId: 2, name: '雁塔区'},
  { id: 10, pId: 2, name: '碑林区'},
  { id: 11, pId: 2, name: '西咸新区'}
]

let data = [
  {
    "id": "1175310929766055936",
    "pid": "",
    "companyId": "1",
    "name": "总裁办",
    "code": "ZCB",
    "managerId": null,
    "manager": "文吉星",
    "introduce": "总裁办公室",
    "createTime": null
  },
  {
    "id": "1175311325720936448",
    "pid": "",
    "companyId": "1",
    "name": "财务部",
    "code": "123213",
    "managerId": null,
    "manager": null,
    "introduce": null,
    "createTime": null
  },
  {
    "id": "1235395178363559936",
    "pid": "1175311325720936448",
    "companyId": "1",
    "name": "财务核算部",
    "code": null,
    "managerId": null,
    "manager": null,
    "introduce": null,
    "createTime": null
  },
  {
    "id": "1235398264104624128",
    "pid": "1175311325720936448",
    "companyId": "1",
    "name": "税务管理部",
    "code": "213",
    "managerId": null,
    "manager": "罗晓晓",
    "introduce": "123",
    "createTime": null
  },
  {
    "id": "1235398536969265152",
    "pid": "1175311325720936448",
    "companyId": "1",
    "name": "税务稽查部",
    "code": null,
    "managerId": null,
    "manager": null,
    "introduce": null,
    "createTime": null
  }
]

console.log(tranListToTreeData(arr, -1))
console.log(tranListToTreeData(data, '', { key: 'id', parentKey: 'pid' }))